package com.dbs.donatebooksystem.controller;


import cn.hutool.core.lang.Dict;
import com.dbs.donatebooksystem.Service.BookTraceService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("bookTrace")
public class BookTraceController {

    @Autowired
    BookTraceService bookTraceService;

    @GetMapping("getAllBooksForUserId")
    public Dict getAllBooksForUserId(@RequestParam("address") String address, Integer userId) {
        return bookTraceService.getAllBooksForUserId(address, userId);
    }

    @GetMapping("registerBook")
    public Dict registerBook(@RequestParam("address") String address
            , String book_name
            , String usages
            , Integer page_count
            , String photo_url
            , String books_code
            , String trace_code
            , String category
            , Integer book_carbon_points
            , Integer donorId
            , String pub_address) {
        return bookTraceService.registerBook(address
                , book_name
                , usages
                , page_count
                , photo_url
                , books_code
                , trace_code
                , category
                , book_carbon_points
                , donorId, pub_address);
    }

    @GetMapping("registerDisinfection")
    public Dict registerDisinfection(@RequestParam("address") String address
            , Integer book_id
            , Boolean is_disinfection
            , Integer disinfection_time
            , Integer count) {
        return bookTraceService.registerDisinfection(address, book_id, is_disinfection, disinfection_time, count);
    }

    @GetMapping("createMsg")
    public Dict createMsg(@RequestParam("address") String address
            , Integer book_id
            , String message
            , Integer user_id) {
        return bookTraceService.createMsg(address, book_id, message, user_id);
    }

    @GetMapping("updateDonationAndPoints")
    public Dict updateDonationAndPoints(@RequestParam("address") String address
            , Integer donorId
            , Integer book_carbon_points) {
        return bookTraceService.updateDonationAndPoints(address, donorId, book_carbon_points);
    }

    @GetMapping("getBookforId")
    public Dict getBookforId(@RequestParam("address") String address, Integer bookId) {
        return bookTraceService.getBookforId(address, bookId);
    }

    @GetMapping("getTransitforId")
    public Dict getTransitforId(@RequestParam("address") String address, Integer transitId) {
        return bookTraceService.getTransitforId(address, transitId);
    }

    @GetMapping("getRecycleforId")
    public Dict getRecycleforId(@RequestParam("address") String address, Integer recycleId) {
        return bookTraceService.getRecycleforId(address, recycleId);
    }

    @GetMapping("getDemandforId")
    public Dict getDemandforId(@RequestParam("address") String address, Integer demandId) {
        return bookTraceService.getDemandforId(address, demandId);
    }

    @GetMapping("getOrderforId")
    public Dict getOrderforId(@RequestParam("address") String address, Integer orderId) {
        return bookTraceService.getOrderforId(address, orderId);
    }

    @GetMapping("getBookMsgforId")
    public Dict getBookMsgforId(@RequestParam("address") String address, Integer msgId) {
        return bookTraceService.getBookMsgforId(address, msgId);
    }

    @GetMapping("getBookMsgforBookId")
    public Dict getBookMsgforBookId(@RequestParam("address") String address, Integer bookId) {
        return bookTraceService.getBookMsgforBookId(address, bookId);
    }

    @GetMapping("hello")//http://localhost:8080/supplychain/hello
    public String hello() {
        return "hello";
    }



}
